
package com.ifcar.app.service;

import com.ifcar.app.util.Tools;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.ConnectivityManager;
import android.preference.PreferenceManager;

public class PushReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
        String action = intent.getAction();
        
        if (ConnectivityManager.CONNECTIVITY_ACTION.equals(action)) {
            boolean enabled = Tools.CheckNetwork(context);
            
            if (enabled && PushService.needPush(context)) {
               
                PushService.startPush(context.getApplicationContext());
            } else {
                
                PushService.cancelPush(context);
            }
        }
    }

}
